import createPersistedstate from 'vuex-persistedstate'
import Vue from 'vue'
import Vuex from 'vuex'
import getters from './getters'
import user from './modules/user'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    username: "",
    password: ""
  },
  modules: {
    // 模块划分
    user,
  },
  getters,
  plugins: [createPersistedstate(
    {
      // 默认存储在localStorage 现改为sessionStorage
      // storage: window.sessionStorage,
      // 本地存储数据的键名
      key: 'mine',
      // 指定需要存储的模块，如果是模块下具体的数据需要加上模块名称，如user.token
      paths: ['user']
    }
  )]
})

export default store
